"use strict";
const utils_index = require("../utils/index.js");
const common_vendor = require("../common/vendor.js");
const defaultOptions = {
  duration: 2e3,
  show: false
};
const useGlobalToast = common_vendor.defineStore("global-toast", {
  state: () => ({
    toastOptions: defaultOptions,
    currentPage: ""
  }),
  getters: {},
  actions: {
    // 打开Toast
    show(option) {
      this.currentPage = utils_index.getCurrentPath();
      const options = common_vendor.deepMerge(defaultOptions, typeof option === "string" ? { msg: option } : option);
      this.toastOptions = common_vendor.deepMerge(options, {
        show: true,
        position: options.position || "middle"
      });
    },
    // 成功提示
    success(option) {
      this.show(common_vendor.deepMerge({
        iconName: "success",
        duration: 1500
      }, typeof option === "string" ? { msg: option } : option));
    },
    // 关闭提示
    error(option) {
      this.show(common_vendor.deepMerge({
        iconName: "error",
        direction: "vertical"
      }, typeof option === "string" ? { msg: option } : option));
    },
    // 常规提示
    info(option) {
      this.show(common_vendor.deepMerge({
        iconName: "info"
      }, typeof option === "string" ? { msg: option } : option));
    },
    // 警告提示
    warning(option) {
      this.show(common_vendor.deepMerge({
        iconName: "warning"
      }, typeof option === "string" ? { msg: option } : option));
    },
    // 关闭Toast
    close() {
      this.toastOptions = defaultOptions;
      this.currentPage = "";
    }
  }
});
exports.useGlobalToast = useGlobalToast;
